package com.sdu.shanyimisapi.controller.form;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.util.Date;

/**
 * @author lihaopeng
 * @version 1.0
 * @project shanyi-mis-api
 * @description 新增App用户
 * @since 2024/4/19 9:50
 */
@Data
public class InsertOrUpdateAppUserForm {

//    @Min(value = 1, message = "id不能小于1")
    private Integer id;

    @NotBlank(message = "username用户名不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9]{5,50}$", message = "username用户名格式不正确，最短5字符，最多50字符")
    private String username;

    @NotBlank(message = "password不能为空")
    @Pattern(regexp = "^[a-zA-Z0-9]{6,20}$", message = "password内容不正确")
    private String password;

    @NotBlank(message = "name姓名不能为空")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,20}$", message = "name姓名内容不正确")
    private String name;

    @NotNull(message = "birthday生日不能为空")
//    @Pattern(regexp = "^((((19|20)\\d{2})-(0?(1|[3-9])|1[012])-(0?[1-9]|[12]\\d|30))|(((19|20)\\d{2})-(0?[13578]|1[02])-31)|(((19|20)\\d{2})-0?2-(0?[1-9]|1\\d|2[0-8]))|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))-0?2-29))$",
//            message = "birthday生日格式不正确")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    @NotBlank(message = "sex性别不能为空")
    @Pattern(regexp = "^男$|^女$", message = "sex性别格式不正确，只能为男或女")
    private String sex;

    @NotBlank(message = "phone手机号不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "phone手机号格式不正确")
    private String phone;

//    @Pattern(regexp = "^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$", message = "email邮箱格式不正确")
    @NotBlank(message = "email邮箱不能为空")
    @Email
    @Length(max = 200, message = "email邮箱内容不正确，最多200字符")
    private String email;

    @NotBlank(message = "address地址不能为空")
    @Length(max = 200, message = "address地址内容不正确，最多200字符")
    private String address;

    @NotBlank(message = "height身高不能为空")
    @Pattern(regexp = "^[0-3]\\.\\d{2}$", message = "height身高格式不正确，单位为米，必须有1位整数和2位小数，如1.83")
    private String height;

    @NotBlank(message = "weight体重不能为空")
    @Pattern(regexp = "^(?:\\d{1,2}|[1-4]\\d{2}|500)\\.\\d$", message = "weight体重格式不正确，单位为千克，最多3位整数，必须有1位小数，范围为0.0到500.0，如65.5")
    private String weight;

    private String[] likes;

    private String[] dislikes;

//    private String avatar;

    @Length(max = 250, message = "shortTermGoal短期目标内容不正确，最多250字符")
    private String shortTermGoal;

    @Length(max = 250, message = "diseases疾病内容不正确，最多250字符")
    private String diseases;

    // @NotBlank注解只能用在字符串上，如果不是字符串类型，都可以使用@NotNull
    @NotNull(message = "status状态码不能为空")
    @Range(min = 0, max = 1, message = "status状态码不正确，0无效（逻辑删除），1有效")
    private Byte status;

//    @NotNull(message = "appActivityId活动id不能为空")
//    @Min(value = 1, message = "appActivityId活动id不能小于1")
//    private Integer appActivityId;

}
